package bomber.model;

import java.util.HashMap;


public class GameButtonPool {

	private HashMap<String, GameButton> buttonMap;

	public GameButtonPool(int size) {
		this.buttonMap = new HashMap<String, GameButton>();
	}

	public GameButton addButton(int type, int i, int j) {
		GameButton gameButton = new GameButton(this.getButtonSet(type));
		this.buttonMap.put(this.getKey(i, j), gameButton);
		return gameButton;
	}

	public GameButton newButton(int type) {
		return new GameButton(this.getButtonSet(type));
	}

	public GameButtonSet getButtonSet(int type) {
		GameButtonSet buttonSet = new GameButtonSet();
		switch (type) {
			case 3: {
				buttonSet.setTextOn("#");
				buttonSet.setColor(0, 0, 220);
				break;
			}
			case 2: {
				buttonSet.setTextOn("X");
				buttonSet.setColor(220, 0, 0);
				break;
			}
			case 1: {
				buttonSet.setTextOn("");
				buttonSet.setColor(180, 180, 180);
				break;
			}
			case 0: {
				buttonSet.setTextOn("");
				buttonSet.setColor(220, 220, 220);
				break;
			}
		}
		return buttonSet;
	}

	public String getKey(int i, int j) {
		return String.format("%d|%d", i, j);
	}

	public HashMap<String, GameButton> getHashMap() {
		return this.buttonMap;
	}
}
